﻿#VisualFreeBasic_Form#  Version=5.9.1
Locked=0

[Form]
Name=Form1
ClassStyle=CS_VREDRAW,CS_HREDRAW,CS_DBLCLKS
ClassName=
WinStyle=WS_THICKFRAME,WS_CAPTION,WS_SYSMENU,WS_MINIMIZEBOX,WS_MAXIMIZEBOX,WS_CLIPSIBLINGS,WS_CLIPCHILDREN,WS_VISIBLE,WS_EX_WINDOWEDGE,WS_EX_CONTROLPARENT,WS_EX_LEFT,WS_EX_LTRREADING,WS_EX_RIGHTSCROLLBAR,WS_POPUP,WS_SIZEBOX
Style=3 - 常规窗口
Icon=
Caption=C语言代码转FreeBasic语言代码
StartPosition=1 - 屏幕中心
WindowState=0 - 正常
Enabled=True
Repeat=False
Left=0
Top=0
Width=628
Height=514
TopMost=False
Child=False
MdiChild=False
TitleBar=True
SizeBox=True
SysMenu=True
MaximizeBox=True
MinimizeBox=True
Help=False
Hscroll=False
Vscroll=False
MinWidth=400
MinHeight=300
MaxWidth=0
MaxHeight=0
NoActivate=False
MousePass=False
TransPer=0
TransColor=SYS,25
Shadow=0 - 无阴影
BackColor=SYS,15
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False
AcceptFiles=True

[Button]
Name=Command5
Index=0
Caption=上
TextAlign=1 - 居中
Ico=
Enabled=True
Visible=True
Default=False
OwnDraw=False
MultiLine=False
Font=微软雅黑,9,0
Left=525
Top=450
Width=35
Height=25
Layout=0 - 不锚定
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False

[Button]
Name=Command4
Index=-1
Caption=直接替换列表
TextAlign=1 - 居中
Ico=
Enabled=True
Visible=True
Default=False
OwnDraw=False
MultiLine=False
Font=微软雅黑,9,0
Left=340
Top=245
Width=85
Height=25
Layout=0 - 不锚定
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False

[Scintilla]
Name=Scintilla1
Explain=
Help=
Index=-1
Style=1 - 细边框
Enabled=True
Visible=True
Left=10
Top=35
Width=500
Height=190
Layout=0 - 不锚定
Tag=
Tab=True

[Scintilla]
Name=Scintilla2
Explain=
Help=
Index=-1
Style=1 - 细边框
Enabled=True
Visible=True
Left=10
Top=275
Width=505
Height=190
Layout=0 - 不锚定
Tag=
Tab=True

[Button]
Name=Command1
Index=-1
Caption=粘贴
TextAlign=1 - 居中
Ico=
Enabled=True
Visible=True
Default=False
OwnDraw=False
MultiLine=False
Font=微软雅黑,9,0
Left=390
Top=5
Width=45
Height=25
Layout=0 - 不锚定
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False

[Button]
Name=Command2
Index=-1
Caption=开始转换
TextAlign=1 - 居中
Ico=
Enabled=True
Visible=True
Default=False
OwnDraw=False
MultiLine=False
Font=微软雅黑,9,0
Left=445
Top=5
Width=70
Height=25
Layout=0 - 不锚定
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False

[CheckBox]
Name=Check1
Index=-1
Style=0 - 标准
Caption=自动翻译英文注解为中文
TextAlign=3 - 中左对齐
Alignment=0 - 文本在左边
Value=0 - 未选择
Multiline=True
Enabled=True
Visible=True
ForeColor=SYS,8
BackColor=SYS,25
Font=微软雅黑,9,0
Left=160
Top=250
Width=165
Height=15
Layout=0 - 不锚定
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False
AcceptFiles=False

[Button]
Name=Command3
Index=-1
Caption=复制代码
TextAlign=1 - 居中
Ico=
Enabled=True
Visible=True
Default=False
OwnDraw=False
MultiLine=False
Font=微软雅黑,9,0
Left=435
Top=245
Width=75
Height=25
Layout=0 - 不锚定
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False

[YFsplitBar]
Name=YFsplitBar1
Index=-1
Style=0 - 无边框
Enabled=True
Visible=True
ForeColor=&H009900
BackColor=SYS,15
Left=0
Top=240
Width=515
Height=5
Tag=
ToolTip=
ToolTipBalloon=False

[Label]
Name=Label1
Index=-1
Style=0 - 无边框
Caption=C语言代码，可以复制粘贴，也可以拖文件过来。
Enabled=True
Visible=True
ForeColor=SYS,8
BackColor=SYS,25
Font=微软雅黑,9,0
FontWidth=0
FontAngle=0
TextAlign=0 - 左对齐
Prefix=True
Ellipsis=False
Left=10
Top=10
Width=325
Height=20
Layout=0 - 不锚定
MousePointer=0 - 默认
Tag=
ToolTip=
ToolTipBalloon=False

[Label]
Name=Label2
Index=-1
Style=0 - 无边框
Caption=FreeBasic语言代码
Enabled=True
Visible=True
ForeColor=SYS,8
BackColor=SYS,25
Font=微软雅黑,9,0
FontWidth=0
FontAngle=0
TextAlign=0 - 左对齐
Prefix=True
Ellipsis=False
Left=5
Top=250
Width=160
Height=20
Layout=0 - 不锚定
MousePointer=0 - 默认
Tag=
ToolTip=
ToolTipBalloon=False

[ListView]
Name=ListView1
Index=-1
Style=1 - 报表视图
BStyle=3 - 凹边框
Theme=False
ImageNormalS=无图像列表控件
ImageSmallS=无图像列表控件
SingleSel=True
ShowSel=True
Sort=0 - 不排序
SortColumn=True
NoScroll=False
AutoArrange=False
EditLabels=False
OwnerData=False
AlignTop=False
AlignLeft=False
OwnDraw=False
ColumnHeader=True
ColumnEditor=序||0|27|处理||0|37|
NoSortHeader=False
BorderSelect=False
Check=False
FlatScrollBars=False
FullRowSelect=True
GridLines=True
HeaderDragDrop=False
InfoTip=False
LabelTip=False
MultiWorkAreas=False
OneClickActivate=False
Regional=False
SimpleSelect=False
SubItemImages=False
TrackSelect=False
TwoClickActivate=False
UnderlineCold=False
UnderlineHot=False
Enabled=True
Visible=True
ForeColor=SYS,8
BackColor=SYS,5
TextBkColor=SYS,5
Font=微软雅黑,9,0
Left=520
Top=5
Width=90
Height=440
Layout=0 - 不锚定
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False
AcceptFiles=False

[Button]
Name=Command5
Index=1
Caption=下
TextAlign=1 - 居中
Ico=
Enabled=True
Visible=True
Default=False
OwnDraw=False
MultiLine=False
Font=微软雅黑,9,0
Left=570
Top=450
Width=35
Height=25
Layout=0 - 不锚定
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False


[AllCode]

Dim Shared 退出翻译              As Long, 百度翻译缓存() As String, 百度翻译缓存更改 As Long
Dim Shared FreeBASIC关键字       As String
Dim Shared 直接替换列表关键词c() As String, 直接替换列表关键词b() As String
Dim Shared As String 百度appid, 百度key, 百度salt
'百度翻译接口，需要英文翻译，请自己去 http://api.fanyi.baidu.com  注册一个账号

'本转换算法是一个字符一个字符去比较，只考虑完成功能，不考虑执行效率
'C语法变化多端，无法应付刁钻的和特殊格式，只针对常用的规范的写法格式做出翻译。
'算法无法支持所有的C代码，只支持遇到过的C代码，遇到什么再改进。
'【注意】很多宏会影响代码格式判断，必须自己先把宏替换掉。算法也无法搞上下文联系和自动宏替换后再分析代码


'[Form1]事件 : 窗口完全显示后。
'hWndForm  当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'UserData  来自显示窗口最后1个参数，例： Form2.Show(父窗口句柄,模式,UserData)
Sub Form1_Shown(hWndForm As hWnd, UserData As Integer)
   '百度翻译接口，需要英文翻译，请自己去 http://api.fanyi.baidu.com  注册一个账号
   百度appid = ""
   百度key   = ""
   百度salt  = ""
   
   FreeBASIC关键字 = "abs abstract access acos add alias allocate alpha and andalso any append as asc asin asm assert assertwarn atan2 atn bload bsave base bin "
   FreeBASIC关键字 &= "binary bit bitreset bitset byref byval byref byte callocate cbyte cdbl cint clng clngint cptr cshort csign csng cubyte cuint culng culngint cushort "
   FreeBASIC关键字 &= "cunsg cvd cvi cvl cvlongint cvs cvshort call case cast chdir chain chartoutf chr circle class clear close cls color command common condbroadcast "
   FreeBASIC关键字 &= "condcreate conddestroy condsignal condwait const const const constructor constructor continue cos csrlin curdir custom data date dateadd datediff "
   FreeBASIC关键字 &= "datepart dateserial datevalue day deallocate declare defbyte defdbl defint deflng defshort defsng defstr defubyte defuint defushort deflongint defulongint "
   FreeBASIC关键字 &= "delete destructor destructor dim dir do double draw draw dylibfree dylibload dylibsymbol eof else elseif encoding end end end if endif enum...end "
   FreeBASIC关键字 &= "environ eqv eqv erase erfn erl ermn error event exepath exec exit exp export extends extern field fileattr filecopy filedatetime fileexists filelen "
   FreeBASIC关键字 &= "fix flip for for format frac fre freefile function function get getjoystick getkey getmouse gosub goto hex hibyte hiword hour iif if imageconvertrow "
   FreeBASIC关键字 &= "imagecreate imagedestroy imp imp implements import instr instrrev inkey inp input int integer is isdate isredirected kill lbound lcase loc lof lprint "
   FreeBASIC关键字 &= "lset ltrim left len let let lib line lobyte loword locate lock log long longint loop lpos mkd mki mkl mklongint mks mkshort mid mid minute mkdir "
   FreeBASIC关键字 &= "mod mod month monthname multikey mutexcreate mutexdestroy mutexlock mutexunlock naked name namespace new next next not now object oct offsetof on "
   FreeBASIC关键字 &= "once open operator option or orelse out output overload override pcopy pmap preset pset pset paint palette peek placement point pointcoord pointer "
   FreeBASIC关键字 &= "poke pos preserve print print print private private: procptr property protected: ptr public put put rgb rgba rset rtrim random randomize redim read "
   FreeBASIC关键字 &= "reallocate rem reset restore resume return right rmdir rnd run sadd scope screen screencontrol screencopy screenevent screenglproc screeninfo screenlist "
   FreeBASIC关键字 &= "screenlock screenptr screenres screenset screensync screenunlock second seek seek select setdate setenviron setmouse settime sgn shared shell shl "
   FreeBASIC关键字 &= "shl short shr shr sin single sizeof sleep space spc sqr static static step step stick stop str strptr strig string sub sub swap system tab tan then "
   FreeBASIC关键字 &= "this threadcreate threadwait threadcall threaddetach time timeserial timevalue timer to trans trim type typeof ubound ubyte ucase uinteger ulong "
   FreeBASIC关键字 &= "ulongint ushort union unlock unsigned until using val valint vallng valuint valulng var varptr view virtual wbin wchr whex woct wspace wstr wstring "
   FreeBASIC关键字 &= "wait weekday weekdayname wend while width window windowtitle winput with write wstring xor year zstring cdecl defined pascal stdcall va_arg va_first "
   FreeBASIC关键字 &= "va_next"
   If AfxFileExists(App.Path & "直接替换列表关键词.txt") = 0 Then
      Dim ss As String = """float""""Single""" & vbCrLf & _
         """bool""""BOOL"""     & vbCrLf & _
         """long""""Integer"""   & vbCrLf & _
         """int""""Long"""   & vbCrLf & _
         """char""""Byte"""     & vbCrLf & _
         """void""""any"""      & vbCrLf & _
         """dword""""ULong"""   & vbCrLf & _
         """double""""Double""" & vbCrLf & _
         """word""""UShort"""   & vbCrLf & vbCrLf & _
         StrToUtf8("遇到空行之后的就忽略替换") & vbCrLf & _
         StrToUtf8("""要替换的C代码""""被替换成的B代码""") & vbCrLf & _
         StrToUtf8("需要用双引号包裹关键词，一行一个替换。")
      SaveFileStrUtf8(App.Path & "直接替换列表关键词.txt", ss)
      'Case "vector2"   : rr = "RayLib.Vector2"
      'Case "rectangle" : rr = "RayLib.Rectangle"
      'Case "color"     : rr = "RayLib.Color"
   End If

   加载直接替换列表()
   Dim ss As String = GetFileStr(App.Path & "百度翻译缓存.txt")
   vbSplit(ss, vbCrLf, 百度翻译缓存())
   设置代码编辑器 Scintilla1.pSci
   设置代码编辑器 Scintilla2.pSci
   Scintilla1.TextAppend StrToUtf8("C语法变化多端，只支持常用的规范写法格式做出翻译。") & vbCrLf
   Scintilla1.TextAppend StrToUtf8("【注意】很多宏会影响代码格式判断，必须自己先把宏替换掉。") & vbCrLf
   Scintilla1.TextAppend StrToUtf8("算法无法支持所有的C代码，只支持遇到过的C代码，遇到什么再改进。") & vbCrLf   
   
   ss = GetFileStrUtf8(App.Path & "备份C代码.txt")
   If Len(ss) Then  Scintilla1.Text =ss 
   ss = GetFileStrUtf8(App.Path & "备份B代码.txt")
   If Len(ss) Then  Scintilla2.Text =ss 
   Me.Caption ="C语言代码转FreeBasic语言代码 " & App.FileMajor & "." & App.FileMinor & "." & App.FileRevision & "." & App.FileBuild & " 勇芳软件开发工作室"   
End Sub

Sub 设置代码编辑器(pSci As Any Ptr ) 

   'SciMsg(pSci, SCI_STYLESETFORE, STYLE_DEFAULT, 窗体文字)
   'SciMsg(pSci, SCI_STYLESETBACK, STYLE_DEFAULT, 窗体底色)
   
   Dim tStr As ZString * 1024 = "Microsoft YaHei Mono"
   SciMsg(pSci, SCI_STYLESETFONT, STYLE_DEFAULT, Cast(lParam, @tStr))
   SciMsg(pSci, SCI_STYLESETSIZE, STYLE_DEFAULT, 10)
   SciMsg(pSci, SCI_STYLESETCHARACTERSET, STYLE_DEFAULT, SC_CHARSET_DEFAULT)
   SciMsg(pSci, SCI_STYLECLEARALL, 0, 0) ' 将全局样式复制到所有其他样式
   '行号宽度
   tStr = "_889"
   Dim nPixels As Long = SciMsg(pSci, SCI_TEXTWIDTH, 0, Cast(lParam, @tStr))
   SciMsg(pSci, SCI_SETMARGINWIDTHN, 0, nPixels)
   
   ' 书签
   SciMsg(pSci, SCI_SETMARGINWIDTHN, 1, 2)
   '行号颜色
   SciMsg(pSci, SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER)
   'SciMsg(pSci, SCI_STYLESETFORE, STYLE_LINENUMBER, 窗体文字)
   'SciMsg(pSci, SCI_STYLESETBACK, STYLE_LINENUMBER, 窗体亮度15)
   ''  TABS 作为空格处理
   SciMsg(pSci, SCI_SETUSETABS, CTRUE, 0)
   ''  TAB 宽度
   SciMsg(pSci, SCI_SETTABWIDTH, 3, 0)
   SciMsg(pSci, SCI_SETINDENT, 3, 0)
   '  显示缩进参考线
   SciMsg(pSci, SCI_SETINDENTATIONGUIDES, CTRUE, 0)
   ''  当前行颜色
   'SciMsg(pSci, SCI_SETCARETLINEBACK, 窗体亮度10, 0)
   SciMsg(pSci, SCI_SETHOTSPOTACTIVEUNDERLINE, CTRUE, 0) '允许
   '''  选择颜色
   'SciMsg(pSci, SCI_SETSELFORE, CTRUE, op.Themes(0).colors(CLR_SELECTION).nFg)
   'SciMsg(pSci, SCI_SETSELBACK, CTRUE, op.Themes(0).colors(CLR_SELECTION).nBg)
   'SciMsg(pSci, SCI_SETHOTSPOTACTIVEUNDERLINE, CTRUE, 0) '允许
   ''  始终保持插入符号行可见
   SciMsg(pSci, SCI_SETCARETLINEVISIBLEALWAYS, CTRUE, 0)
   ''  标识要在单词中使用的字符
   tStr = "&~_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
   SciMsg(pSci, SCI_SETWORDCHARS, 0, Cast(lParam, @tStr))
   '为了在编辑器中显示，utf8或utf16将被转换为utf8。
   SciMsg(pSci, SCI_SETCODEPAGE, SC_CP_UTF8, 0)
   'SciMsg(pSci, SCI_SETSCROLLWIDTHTRACKING, True, 0) '滚动宽度跟踪，则调整滚动宽度以确保当前显示的所有行都可以完全滚动。
   SciMsg(pSci, SCI_SETSCROLLWIDTH, 10000, 10000)
   'SciMsg(pSci, SCI_SETVSCROLLBAR, 0, 0)
   'SciMsg(pSci, SCI_SETHSCROLLBAR, 0, 0)
   SciMsg(pSci, SCI_SETLEXER, SCLEX_VB, 0)
   '设置FreeBASIC关键字
   'If Len(op.FBKeywordsC) Then
   SciMsg(pSci, SCI_SETKEYWORDS, 0, Cast(lParam, StrPtr(FreeBASIC关键字)))
   'End If
   
   'If Len(op.APIKeywordsC) Then
   '   SciMsg(pSci, SCI_SETKEYWORDS, 1, Cast(lParam, StrPtr(op.APIKeywordsC)))
   'End If
   '设置多行注释样式
   SciMsg(pSci, SCI_STYLESETFORE, SCE_B_MULTILINECOMMENT, BGR(77, 153, 0))
   'SciMsg(pSci, SCI_STYLESETBACK, SCE_B_MULTILINECOMMENT, op.Themes(0).colors(CLR_COMMENTS).nBg)
   
   '设置注释样式
   SciMsg(pSci, SCI_STYLESETFORE, SCE_B_COMMENT, BGR(77, 153, 0))
   'SciMsg(pSci, SCI_STYLESETBACK, SCE_B_COMMENT, op.Themes(0).colors(CLR_COMMENTS).nBg)
   
   '设置关键字样式
   SciMsg(pSci, SCI_STYLESETFORE, SCE_B_KEYWORD, BGR(0, 0, 229))
   'SciMsg(pSci, SCI_STYLESETBACK, SCE_B_KEYWORD, op.Themes(0).colors(CLR_KEYWORD).nBg)
   
   'SciMsg(pSci, SCI_STYLESETFORE, SCE_B_KEYWORD2, 色差补色GDItoGDI(主色调, 60))
   ''SciMsg(pSci, SCI_STYLESETBACK, SCE_B_KEYWORD2, op.Themes(0).colors(CLR_API).nBg)
   '
   'SciMsg(pSci, SCI_STYLESETFORE, SCE_B_KEYWORD3, 色差补色GDItoGDI(主色调, 60))
   ''SciMsg(pSci, SCI_STYLESETBACK, SCE_B_KEYWORD3, op.Themes(0).colors(CLR_Lib).nBg)
   
   '设置标识符样式
   'SciMsg(pSci, SCI_STYLESETFORE, SCE_B_IDENTIFIER, 色差补色GDItoGDI(主色调, 120))
   'SciMsg(pSci, SCI_STYLESETBACK, SCE_B_IDENTIFIER, op.Themes(0).colors(CLR_TEXT).nBg)
   
   '设置数字样式
   SciMsg(pSci, SCI_STYLESETFORE, SCE_B_NUMBER, BGR(0, 178, 178))
   'SciMsg(pSci, SCI_STYLESETBACK, SCE_B_NUMBER, op.Themes(0).colors(CLR_TEXT).nBg)
   
   '设置运算符样式
   SciMsg(pSci, SCI_STYLESETFORE, SCE_B_OPERATOR, BGR(178, 0, 178))
   'SciMsg(pSci, SCI_STYLESETBACK, SCE_B_OPERATOR, op.Themes(0).colors(CLR_OPERATORS).nBg)
   
   '设置预处理样式
   SciMsg(pSci, SCI_STYLESETFORE, SCE_B_PREPROCESSOR, BGR(102, 0, 204))
   'SciMsg(pSci, SCI_STYLESETBACK, SCE_B_PREPROCESSOR, op.Themes(0).colors(CLR_PREPROCESSOR).nBg)
   
   '设置字符串样式
   SciMsg(pSci, SCI_STYLESETFORE, SCE_B_STRING, BGR(178, 0, 89))
   'SciMsg(pSci, SCI_STYLESETBACK, SCE_B_STRING, op.Themes(0).colors(CLR_STRINGS).nBg)
   

End Sub

'[Form1]事件 : 窗口已经改变了大小
'hWndForm  当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'fwSizeType = SIZE_MAXHIDE     SIZE_MAXIMIZED   SIZE_MAXSHOW    SIZE_MINIMIZED    SIZE_RESTORED  
''            其他窗口最大化   窗口已最大化     其他窗口恢复    窗口已最小化      窗口已调整大小
'nWidth nHeight  是客户区大小，不是全部窗口大小。
Sub Form1_WM_Size(hWndForm As hWnd, fwSizeType As Long, nWidth As Long, nHeight As Long)
   if fwSizeType = SIZE_MINIMIZED Then Return
   'xxx.Move DpiScaleI(5), DpiScaleI(5), nWidth - DpiScaleI(10), nHeight - DpiScaleI(30)
   ListView1.Move nWidth - DpiScaleI(90), DpiScaleI(5), DpiScaleI(85), nHeight - DpiScaleI(10+28)
   Command5(0).Move nWidth - DpiScaleI(85),nHeight - DpiScaleI(10+20)
   Command5(1).Move nWidth - DpiScaleI(45),nHeight - DpiScaleI(10+20)
   
   Command1.Move nWidth  - DpiScaleI(125 + 90), DpiScaleI(5)
   Command2.Move nWidth  - DpiScaleI(75 + 90), DpiScaleI(5)
   Dim f As Long = YFsplitBar1.Value
   If f > nHeight - DpiScaleI(150) Then f = nHeight - DpiScaleI(150)
   YFsplitBar1.Move 0, f, nWidth-DpiScaleI(90), DpiScaleI(5)
   Scintilla1.Move DpiScaleI(5), DpiScaleI(30), nWidth - DpiScaleI(10+90), f - DpiScaleI(31)
   Label2.Move DpiScaleI(5), f + DpiScaleI(10)
   Check1.Move nWidth   - DpiScaleI(340+90), f + DpiScaleI(8)
   Command3.Move nWidth - DpiScaleI(80+90), f  + DpiScaleI(5)
   Command4.Move nWidth - DpiScaleI(170+90), f + DpiScaleI(5)
   Scintilla2.Move DpiScaleI(5), f + DpiScaleI(30), nWidth - DpiScaleI(10+90), nHeight - f - DpiScaleI(35)
   
   
End Sub


'[Form1.YFsplitBar1]事件 : 正在拖动分割条
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
'old_vv =旧的位置 new_vv=新的位置，返回非零不允许拖动，单位是像素
Function Form1_YFsplitBar1_Dragging(hWndForm As hWnd, hWndControl As hWnd, old_vv As Long, new_vv As Long) As Long
   If new_vv < DpiScaleI(100) Then Return True
   If new_vv > Me.ScaleHeight - DpiScaleI(150) Then Return True

   Function = False ' 返回 TRUE 不允许拖动
End Function

'[Form1.YFsplitBar1]事件 : 结束拖动分割条
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
'vv          当前控件位置值，单位是像素
Sub Form1_YFsplitBar1_DragEnd(hWndForm As hWnd, hWndControl As hWnd,vv As Long )
   Form1_WM_Size(hWndForm, 0, Me.ScaleWidth, Me.ScaleHeight)

End Sub

'[Form1]事件 : 当用户将文件拖放到已启用接收的应用程序窗口中
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hDrop       操作系统发来的拖拽数据，里面包括文件名等。
' !!!注意!!!! 需要窗口编辑里 "拖放"属性选择允许后，才可用。
Sub Form1_WM_DropFiles(hWndForm As hWnd, HDROP As HDROP)
   Dim u As Long = DragQueryFile(hDrop, -1, Null, 0) '获取文件个数
   If u Then
      Dim nFile As wString * (MAX_PATH + 1), re As Long, i As Long
      For i = 0 To u -1
         re = DragQueryFileW(hDrop, i, @nFile, MAX_PATH) '获取文件名，返回文件名的字符个数
         If re Then
            'nFile 包含路径的文件名，这里是宽字符版，要获取 A字符，使用 Dim nFile As zString 和 DragQueryFileA
            Dim pp As CWSTR = GetFileStrW(nFile)
            Dim ci As Long
            If Len( **pp) Then
               For ci = 0 To Len( **pp) -1
                  If (pp[ci] < 32 And pp[ci] <> 13 And pp[ci] <> 10) Or pp[ci] > 127 And pp[ci] < &H4E00 Then
                     pp[ci] = 32
                  End If
               Next
            End If
            Form1.Scintilla1.SendMessage(SCI_SETSEL, 0, Form1.Scintilla1.GetTextLength)
            Scintilla1.TextSel = pp.utf8
            Scintilla1.SetFocus
            Return
         End If
      Next
   End If
   
   
End Sub

'[Form1.Command1]事件 : 单击
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
Sub Form1_Command1_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd)
   '在实际应用中，遇到不可显示字符，影响了语法分析，造成错误，因此增加去掉会显示字符
   Dim pp As CWSTR = AfxGetClipboardText()
   Dim ci As Long
   If Len( **pp) then
      For ci = 0 To Len( **pp) -1
         If (pp[ci] < 32 And pp[ci] <> 13 And pp[ci] <> 10) Or pp[ci] > 127 And pp[ci] < &H4E00 Then
            pp[ci] = 32
         End If
      Next
   End If
   
   Form1.Scintilla1.SendMessage(SCI_SETSEL, 0, Form1.Scintilla1.GetTextLength)
   Scintilla1.TextSel = pp.utf8
   Scintilla1.SetFocus
End Sub

'[Form1.Command3]事件 : 单击
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
Sub Form1_Command3_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd)
   AfxSetClipboardText(UTF8toCWSTR(Scintilla2.text))
End Sub

'[Form1.Command2]事件 : 单击
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
Sub Form1_Command2_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd)
   Me.Enabled = False
   代码处理i  = 1
   代码处理u  = 0
   代码处理t = GetTickCount
   Form1.ListView1.DeleteAllItems
   If Form2.hWnd Then Form2.Close
   Form2.Show(hWndForm)
   退出翻译 = 0
   DoEventsEX 300
   Threaddetach ThreadCreate(Cast(Any Ptr, @执行转换线程), 0) '经典调用方法
End Sub

Sub 执行转换线程(nn As Long)
   Dim C代码 As String = Scintilla1.Text
   If Len(C代码) = 0 Then
      Me.Enabled = True
      Form2.Close
      Return
   End If
   Dim B代码 As String = C代码转换B代码(C代码)
   SendMessage( Form1.hWnd , &H1122 , 0 ,Cast(lParam,@B代码))  '避免多线程下操作控件可能发生意外，利用消息，同线程操作控件。
   Me.Enabled      = True
   Form2.Close
End Sub

Function C代码转换B代码(C代码 As String) As String
   Dim B代码 As String
   Dim ci As Long, 空格 As Long, 配对语句 As String, 未处理代码 As String, 单引号 As Long, 双引号 As Long,括号 As Long 
   If C代码 = "" Then Return ""

   翻译主要 += 1
   If 翻译主要 = 1 Then 代码处理u = Len(C代码)
   For ci = 1 To Len(C代码)
      If 退出翻译     Then Exit For
      If 翻译主要 = 1 Then 代码处理i = ci
      If Mid(C代码, ci, 1) = " " Then
         空格       += 1
         未处理代码 &= " "
         Continue For
      Else
         'If 空格 Then B代码 &= Space(空格)
         空格 = 0
      End If
      If Mid(C代码, ci, 2) = vbCrLf Then
         未处理代码 &= vbCrLf
         ci         += 1
         Continue For
      End If
      If 单引号 = 1 Then
         If Mid(C代码, ci, 1) = "'" Then
            单引号     = 0
            未处理代码 &= """"
         Else
            未处理代码 &= Mid(C代码, ci, 1)
         end if
         Continue For
      End If
      If 双引号 = 1 Then
         If Mid(C代码, ci, 1) = """" Then 双引号 = 0
         未处理代码 &= Mid(C代码, ci, 1)
         Continue For
      End If
      If Mid(C代码, ci, 1) = "'" Then
         单引号     = 1
         未处理代码 &= """"
         Continue For
      End If
      If Mid(C代码, ci, 1) = """" Then
         双引号     = 1
         未处理代码 &= """"
         Continue For
      End If
      If 括号 = 1 Then 
         If Mid(C代码, ci, 1) = ")" Then 括号 = 0
         未处理代码 &= Mid(C代码, ci, 1)
         Continue For         
      End If      
      If Mid(C代码, ci, 1) = "(" Then
         括号     = 1
         未处理代码 &= "("
         Continue For
      End If      
      If Mid(C代码, ci, 2) = "/*" Then
         处理语句开始符号(ci, C代码, B代码, 未处理代码, 配对语句)
         处理多行注解(ci, C代码, B代码)
         Continue For
      End If
      If Mid(C代码, ci, 2) = "//" Then
         处理语句开始符号(ci, C代码, B代码, 未处理代码, 配对语句)
         处理单行注解(ci, C代码, B代码)
         Continue For
      End If
      If Mid(C代码, ci, 8) = "#include" Then
         未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
         处理引用(ci, C代码, B代码)
         Continue For
      End If
      If Mid(C代码, ci, 8) = "#define " OrElse _
         Mid(C代码, ci, 4) = "#if " OrElse  _
         Mid(C代码, ci, 6) = "#elif " OrElse  _
         Mid(C代码, ci, 5) = "#else" OrElse  _
         Mid(C代码, ci, 6) = "#endif" Then
            未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
         处理直接一行(ci, C代码, B代码)
         Continue For
      End If
      If Mid(C代码, ci, 1) = "}" Then
         未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
         处理结尾(ci, C代码, B代码, 配对语句)
         Continue For
      End If
      If Mid(C代码, ci, 1) = ";" Then
         处理语句结束符号(ci, C代码, B代码, 未处理代码)
         Continue For
      End If
      If Mid(C代码, ci, 1) = "{" Then
         处理语句开始符号(ci, C代码, B代码, 未处理代码, 配对语句)
         Continue For
      End If
      If Mid(C代码, ci, 1) = "?" Then
         处理三元运算符(ci, C代码, B代码, 未处理代码)
         Continue For
      End If
      If 未处理代码 = "" OrElse InStr(vbCrLf & " ~`!@#$%^&*()-=+[]{}\|;:'"",.<>/?", Right(未处理代码, 1)) > 0 Then
         If Mid(C代码, ci, 8) = "typedef " Or  Mid(C代码, ci, 8) = "typedef" & vbCr  Then
            未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
            ci += 8
            Dim si As Long = Len(C代码)
            For pi As Long = ci To Len(C代码)
               If Mid(C代码, pi, 1) <> " " And  Mid(C代码, pi, 1) <> vbCr And   Mid(C代码, pi, 1) <> vbLf Then
                  si = pi
                  Exit For
               End If
            Next
            ci = si
            If Mid(C代码, ci, 7) = "struct " Or Mid(C代码, ci, 7) = "struct{" Or Mid(C代码, ci, 7) = "struct" & vbCr Then
               处理类定义(ci, C代码, B代码, "", "")
               Continue For
            End If
            If Mid(C代码, ci, 5) = "enum " Or Mid(C代码, ci, 5) = "enum{" Or Mid(C代码, ci, 5) = "enum" & vbCr  Then
               处理枚举定义(ci, C代码, B代码)
               Continue For
            End If
            '剩余就是函数定义了，可能也有其它的，目前没遇到
            处理函数定义(ci, C代码, B代码)
            Continue For
         End If
         If Mid(C代码, ci, 7) = "struct " Or Mid(C代码, ci, 7) = "struct{" Or Mid(C代码, ci, 7) = "struct" & vbCr   Then
            未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
            处理类定义(ci, C代码, B代码, "", "")
            Continue For
         End If
         If Mid(C代码, ci, 5) = "enum " Or Mid(C代码, ci, 5) = "enum{" Or Mid(C代码, ci, 5) = "enum" & vbCr   Then
            未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
            处理枚举定义(ci, C代码, B代码)
            Continue For
         End If
         If Mid(C代码, ci, 7) = "static " Or  Mid(C代码, ci, 7) = "static" & vbCr  Then
            未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
            处理静态变量定义(ci, C代码, B代码)
            Continue For
         End If
         If Mid(C代码, ci, 7) = "extern " Or  Mid(C代码, ci, 7) = "extern" & vbCr  Then
            未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
            处理extern(ci, C代码, B代码)
            配对语句 &= "End Extern"
            Continue For
         End If
         If Mid(C代码, ci, 7) = "return " Or Mid(C代码, ci, 7) = "return" & vbCr  Then
            未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
            处理return(ci, C代码, B代码)
            Continue For
         End If
         If Mid(C代码, ci, 3) = "if " Or Mid(C代码, ci, 3) = "if(" Or Mid(C代码, ci, 3) = "if"  & vbCr Then
            未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
            处理条件IF(ci, C代码, B代码, 配对语句)
            Continue For
         End If
         If Mid(C代码, ci, 5) = "else " Or  Mid(C代码, ci, 5) = "else"  & vbCr Then
            未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
            处理条件else(ci, C代码, B代码, 配对语句)
            Continue For
         End If
         If Mid(C代码, ci, 4) = "for " Or Mid(C代码, ci, 4) = "for(" Or Mid(C代码, ci, 4) = "for"  & vbCr   Then
            未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
            处理循环FOR(ci, C代码, B代码, 配对语句)
            
            Continue For
         End If
         If Mid(C代码, ci, 6) = "while " Or Mid(C代码, ci, 6) = "while(" Or Mid(C代码, ci, 6) = "while"  & vbCr   Then
            未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
            处理while(ci, C代码, B代码, 配对语句)
            Continue For
         End If
         If Mid(C代码, ci, 7) = "switch " Or Mid(C代码, ci, 7) = "switch(" Or Mid(C代码, ci, 7) = "switch"  & vbCr  Then
            未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
            处理switch(ci, C代码, B代码, 配对语句)
            Continue For
         End If
         If Mid(C代码, ci, 5) = "case " Or Mid(C代码, ci, 5) = "case("  Or Mid(C代码, ci, 5) = "case" & vbCr Then
            未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
            处理case(ci, C代码, B代码)
            Continue For
         End If
         If Mid(C代码, ci, 6) = "break " Or Mid(C代码, ci, 6) = "break;" Or Mid(C代码, ci, 6) = "break" & vbCr   Then
            未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
            处理break(ci, C代码, B代码,配对语句)
            Continue For
         End If
         If Mid(C代码, ci, 8) = "default " Or Mid(C代码, ci, 8) = "default:" Or Mid(C代码, ci, 8) = "default" & vbCr  Then
            未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
            处理default(ci, C代码, B代码)
            Continue For
         End If
         If Mid(C代码, ci, 6) = "union " Or Mid(C代码, ci, 6) = "union" & vbCr Then
            未处理代码处理(ci - Len(未处理代码), B代码, 未处理代码)
            处理union(ci, C代码, B代码)
            Continue For
         End If         
      End If
      未处理代码 &= Mid(C代码, ci, 1)
   Next
   If Len(未处理代码) Then
      直接替换关键词(未处理代码)
      B代码      &= 未处理代码
      未处理代码 = ""
   End If
   If Left(B代码, 2) = vbCrLf Then B代码 = Mid(B代码, 3)
   翻译主要 -= 1
   Function = B代码
End Function

'[Form1.Command4]事件 : 单击
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
Sub Form1_Command4_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd)
   Form3.Show(hWndForm, True)
   
End Sub

'[Form1]事件 : 即将关闭窗口，返回非0可阻止关闭
'hWndForm  当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
Function Form1_WM_Close(hWndForm As hWnd) As LResult
   If 百度翻译缓存更改 Then
      Dim ss As String = YF_Join(百度翻译缓存(), vbCrLf)
      SaveFileStr(App.Path & "百度翻译缓存.txt", ss)
   End If
   Dim ss As String
   If Scintilla1.IsCanUndo Then
      ss = Scintilla1.Text
      SaveFileStrUtf8(App.Path & "备份C代码.txt", ss)
   End If
   If Scintilla2.IsCanUndo Then
      ss = Scintilla2.Text
      SaveFileStrUtf8(App.Path & "备份B代码.txt", ss)
   end if
   Function = False ' 返回 TRUE 阻止关闭窗口。
End Function

'[Form1.ListView1]事件 : 有个项目已经被改变
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
'pNMV.iItem  当前被更改的项目索引，但为-1时，则更改已应用于列表视图中的所有项目 
'注意：每次点击会发生3次事件，代码新增、修改状态也会发生事件，一般用 pNMV.uNewState = 3 来判断是用户点击后发生的事件。
Sub Form1_ListView1_LVN_ItemChanged(hWndForm As hWnd, hWndControl As hWnd, pNMV As NM_LISTVIEW)
   If pNMV.uNewState <> 3       Then Return '非用户点击和去除一次点击多次事件，可根据实际情况相应修改。
   If ListView1.Enabled = False Then Return
   Dim li As Long = pNMV.iItem
   If li = -1 Then Return
   Dim i As Long = pNMV.lParam
   If i < 0 Or i > UBound(翻译列表) Then Return
   'Text1.Text = ListView1.GetItemText(pNMV.iItem, 1)
   显示行数当中(Form1.Scintilla1.pSci, 翻译列表(i).ci -1, 翻译列表(i).ci + Len(翻译列表(i).C代码))
   显示行数当中(Form1.Scintilla2.pSci, 翻译列表(i).bi -1, 翻译列表(i).bi + Len(翻译列表(i).b代码))
   
   'Form1.Scintilla1.SendMessage(SCI_SETXOFFSET, 0, 0)
   'Form1.Scintilla1.SendMessage(SCI_SETSEL, 翻译列表(i).ci -1,翻译列表(i).ci + Len(翻译列表(i).C代码))
   'Form1.Scintilla2.SendMessage(SCI_SETXOFFSET, 0, 0)
   'Form1.Scintilla2.SendMessage(SCI_SETSEL, 翻译列表(i).bi -1, 翻译列表(i).bi + Len(翻译列表(i).b代码))
   AfxSetClipboardText( """" & ListView1.GetItemText(li, 1) & """")
End Sub

Sub 显示行数当中(pSci As Any Ptr ,nPos As Long,nLength As Long  ) 
   Dim nLine As Long = SciMsg(pSci ,SCI_LINEFROMPOSITION ,nPos ,0)  '目标行
   Dim aLine As Long = SciMsg(pSci ,SCI_GETFIRSTVISIBLELINE ,0 ,0)  '第一行
   Dim uLine As Long = SciMsg(pSci ,SCI_LINESONSCREEN ,0 ,0)        '可显示行数
   Dim mPos  As Long = SciMsg(pSci ,SCI_POSITIONFROMLINE ,nLine ,0) '返回与行首相对应的文档位置   
   aLine = nLine - uLine / 2 + 1
   SciMsg(pSci ,SCI_SETXOFFSET, 0, 0)
   SciMsg(pSci ,SCI_SCROLLRANGE ,mPos ,nPos)
   SciMsg(pSci ,SCI_SETFIRSTVISIBLELINE ,aLine ,0)
   SciMsg(pSci ,SCI_SETSEL ,nPos ,nLength)   
   
End Sub

'[Form1.Scintilla1]事件 : 释放鼠标左键
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
'MouseFlags  MK_CONTROL   MK_LBUTTON     MK_MBUTTON     MK_RBUTTON    MK_SHIFT     MK_XBUTTON1       MK_XBUTTON2 
''           CTRL键按下   鼠标左键按下   鼠标中键按下   鼠标右键按下  SHIFT键按下  第一个X按钮按下   第二个X按钮按下
'检查什么键按下用  If (MouseFlags And MK_CONTROL)<>0 Then CTRL键按下 
'xPos yPos   当前鼠标位置，相对于控件。就是在控件里的坐标。
Sub Form1_Scintilla1_WM_LButtonUp(hWndForm As hWnd, hWndControl As hWnd, MouseFlags As Long, xPos As Long, yPos As Long)
   Dim si As Long = Scintilla1.CurrentPos
   Dim i  As Long, u As Long = ListView1.ItemCount -1, li As Long
   If u = -1 Then Return
   For i = 0 To u
      li = ListView1.ItemData(i)
      If li >= 0 And li <= UBound(翻译列表) Then
         If si >= 翻译列表(i).ci And si <= 翻译列表(i).ci + Len(翻译列表(i).C代码) Then
            显示行数当中(Form1.Scintilla2.pSci, 翻译列表(i).bi -1, 翻译列表(i).bi + Len(翻译列表(i).b代码))
            ListView1.Enabled =False 
            ListView1.SelectedItem = i
            ListView1.Enabled =True 
            Exit For
         End If
      End If
   Next
   
End Sub


'[Form1.Scintilla2]事件 : 释放鼠标左键
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
'MouseFlags  MK_CONTROL   MK_LBUTTON     MK_MBUTTON     MK_RBUTTON    MK_SHIFT     MK_XBUTTON1       MK_XBUTTON2 
''           CTRL键按下   鼠标左键按下   鼠标中键按下   鼠标右键按下  SHIFT键按下  第一个X按钮按下   第二个X按钮按下
'检查什么键按下用  If (MouseFlags And MK_CONTROL)<>0 Then CTRL键按下 
'xPos yPos   当前鼠标位置，相对于控件。就是在控件里的坐标。
Sub Form1_Scintilla2_WM_LButtonUp(hWndForm As hWnd, hWndControl As hWnd, MouseFlags As Long, xPos As Long, yPos As Long)
   Dim si As Long = Scintilla2.CurrentPos
   Dim i  As Long, u As Long = ListView1.ItemCount -1, li As Long
   If u = -1 Then Return
   For i = 0 To u
      li = ListView1.ItemData(i)
      If li >= 0 And li <= UBound(翻译列表) Then
         If si >= 翻译列表(i).bi And si <= 翻译列表(i).bi + Len(翻译列表(i).b代码) Then
            显示行数当中(Form1.Scintilla1.pSci, 翻译列表(i).ci -1, 翻译列表(i).ci + Len(翻译列表(i).C代码))
            ListView1.Enabled =False 
            ListView1.SelectedItem = i
            ListView1.ScrollSelectedItem
            ListView1.Enabled =True 
            Exit For
         End If
      End If
   Next

End Sub

'[Form1.Command5]事件 : 单击
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
Sub Form1_Command5_BN_Clicked(ControlIndex As Long, hWndForm As hWnd, hWndControl As hWnd)
   Dim i As Long = ListView1.SelectedItem
   Dim u As Long = ListView1.ItemCount -1
   if u < 0 then return
   If ControlIndex = 0 Then i -= 1 Else i += 1
   If i < 0 Then i = 0
   If i > u Then i = u
   ListView1.SelectedItem = i
   ListView1.ScrollSelectedItem
   
End Sub

'[Form1]事件 : 自定义消息（全部消息），在其它事件处理后才轮到本事件。
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'wMsg        消息值，0--&H400 由WIN系统定义，用户自定义是 WM_USER+** 定义。例 PostMessage( 窗口句柄 , Msg , wParam , lParam ) 
'wParam      主消息参数，什么作用，由发送消息者定义
'lParam      副消息参数，什么作用，由发送消息者定义
Function Form1_Custom(hWndForm As hWnd, wMsg As UInteger, wParam As wParam, lParam As lParam) As LResult
   Select Case wMsg
      Case &H1122
         Dim B代码 As String Ptr = Cast(Any Ptr, lParam)
         Form1.Scintilla2.SendMessage(SCI_SETSEL, 0, Form1.Scintilla2.GetTextLength)
         Scintilla2.TextSel = *B代码
   End Select
   Function = False ' 若不想系统继续处理此消息，则应返回 TRUE （俗称吃掉消息）。
   
End Function


























